<%--
  Author: Duminda Dharmakeerthi
          Kusal Samarakoon
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script src="${pageContext.request.contextPath}/lib/validation/jquery.validate.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/lib/validation/cmxforms.js" type="text/javascript"></script>

<style type="text/css">
    #menu span, #menu a {
        display: none;
    }

    #content-wrapper-applicant {
        background: #DDD;
    }

    #login {
        border: 1px solid #DAC083;
        background: #FBF5EF;
        width: 300px;
        margin: 30px auto;
        padding: 10px;
        display: block;
        border-radius: 15px;
        box-shadow: 3px 3px 3px #CCC;
    }

    #login .title {
        text-align: center;
        clear: both;
        font-size: 14pt;
        background: #DAC083;
        padding: 5px;
        border-radius: 15px 15px 0 0;
        margin: -10px -10px 10px -10px;
    }

    #login-form {
        font-size: 12pt;
    }

    #login-form .text {
        border: 1px solid #AAA;
        background: #FFF;
        color: #444;
    }

    .btn {
        font-weight: bold;
    }

</style>
<%--<div id="login-slide">--%>
<%--
<script type="text/javascript">
    var ua = navigator.userAgent.toLowerCase();
    var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
    document.getElementById("isAndroid").value = isAndroid;
</script>
--%>

<script type="text/javascript">

    $(document).ready(function () {
        setFocus()
    });

    function setFocus() {
        inVisible();
        document.getElementById("web-browser").style.display = 'none';
        //document.forms[0].userName.focus();
        document.loginForm.username.focus();
    }

    var BrowserDetect = {
        init: function () {

            this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
            this.version = this.searchVersion(navigator.userAgent)
                    || this.searchVersion(navigator.appVersion)
                    || "an unknown version";
            this.OS = this.searchString(this.dataOS) || "an unknown OS";
        },
        searchString: function (data) {
            for (var i = 0; i < data.length; i++) {
                var dataString = data[i].string;
                var dataProp = data[i].prop;
                this.versionSearchString = data[i].versionSearch || data[i].identity;
                if (dataString) {
                    if (dataString.indexOf(data[i].subString) != -1)
                        return data[i].identity;
                }
                else if (dataProp)
                    return data[i].identity;
            }
        },
        searchVersion: function (dataString) {
            var index = dataString.indexOf(this.versionSearchString);
            if (index == -1) return;
            return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
        },
        dataBrowser: [
            {
                string: navigator.userAgent,
                subString: "Chrome",
                identity: "Chrome"
            },
            {
                string: navigator.userAgent,
                subString: "OmniWeb",
                versionSearch: "OmniWeb/",
                identity: "OmniWeb"
            },
            {
                string: navigator.vendor,
                subString: "Apple",
                identity: "Safari",
                versionSearch: "Version"
            },
            {
                prop: window.opera,
                identity: "Opera"
            },
            {
                string: navigator.vendor,
                subString: "iCab",
                identity: "iCab"
            },
            {
                string: navigator.vendor,
                subString: "KDE",
                identity: "Konqueror"
            },
            {
                string: navigator.userAgent,
                subString: "Firefox",
                identity: "Firefox"
            },
            {
                string: navigator.vendor,
                subString: "Camino",
                identity: "Camino"
            },
            {
                // for newer Netscapes (6+)
                string: navigator.userAgent,
                subString: "Netscape",
                identity: "Netscape"
            },
            {
                string: navigator.userAgent,
                subString: "MSIE",
                identity: "Explorer",
                versionSearch: "MSIE"
            },
            {
                string: navigator.userAgent,
                subString: "Gecko",
                identity: "Mozilla",
                versionSearch: "rv"
            },
            {
                // for older Netscapes (4-)
                string: navigator.userAgent,
                subString: "Mozilla",
                identity: "Netscape",
                versionSearch: "Mozilla"
            }
        ],
        dataOS : [
            {
                string: navigator.platform,
                subString: "Win",
                identity: "Windows"
            },
            {
                string: navigator.platform,
                subString: "Mac",
                identity: "Mac"
            },
            {
                string: navigator.userAgent,
                subString: "iPhone",
                identity: "iPhone/iPod"
            },
            {
                string: navigator.platform,
                subString: "Linux",
                identity: "Linux"
            }
        ]

    };
    BrowserDetect.init();
    function inVisible() {
        if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
            var ffversion = new Number(RegExp.$1) // capture x.x portion and store as a number
            if (ffversion < 3.6) {
                alert("your FireFox  version is less than 3.6, then get the latest version from here");
                document.getElementById("login-table").style.display = 'none';
                document.getElementById("incorrectUsername").style.display = 'none';
                document.getElementById("web-browser").style.display = 'block';
            }

        } else if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
            //For Chrome Login
        } else if (/Android[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
            //For Android Login
        }
                <%--commenting temporarily for QA performance testing script generation. uncomment soon after!! -- Ashoka--. --%>
        else {
            /* alert('You\'re using ' + BrowserDetect.browser + ' ' +
             BrowserDetect.version + ' on ' + BrowserDetect.OS + '\n But recommended web Browser is FireFox 3.6 or above \n Download the FireFox Web Browser From Here');
             window.location = "/../downloads/Firefox_Setup_3.6.8.exe";*/
            document.getElementById("login-table").style.display = 'none';
            document.getElementById("web-browser").style.display = 'block';
            document.getElementById("web-browser-lable-01").style.display = 'none';
            document.getElementById("incorrectUsername").style.display = 'none';
        }
    }


</script>

<body>
<div id="login">

    <div class="title"><s:label value="%{getText('login.label')}"/></div>


    <div id="web-browser" style="text-align:center;width:100%;display:none">
        <script type="text/javascript">
            document.write('<p class="accent">* You\'re using ' +
                    BrowserDetect.browser + ' ' + BrowserDetect.version +
                    ' on ' + BrowserDetect.OS + '!</p>');
        </script>

        <div id="web-browser-lable-01">
            <s:label value="* your FireFox  version is less than 3.6"
                     cssStyle="width:80%"/>
        </div>
        <div id="web-browser-lable-02">
            <s:label cssClass="bold-label-tag" value="* Recommended web Browser is FireFox 3.6 or above"
                     cssStyle="width:80%"/>
        </div>
        <div id="firefox-new">
            * Download The Recommended FireFox Web Browser <a href="http://www.mozilla.org/en-US/firefox/new/">from
            here</a>
        </div>
    </div>

    <s:form action="/login.do" method="POST" id="loginForm">
    <table align="center" border="0" cellpadding="0" cellspacing="0" width="50%" id="login-table">
        <tr>
            <td colspan="2" class="left-align">
                <div class="action-msg"><s:actionmessage/></div>
                <div class="action-err"><s:actionerror/></div>
            </td>

        </tr>
        <tr>
                <%--<td><s:label value="%{getText('user_name.label')}"/></td>--%>
            <td><s:label value="%{getText('user_name.label')}"/></td>
            <td><s:textfield name="username" cssClass="text"/></td>
        </tr>
        <tr>
                <%--<td><s:label value="%{getText('password.label')}"/></td>--%>
            <td><s:label value="%{getText('password.label')}"/></td>
            <td><s:password name="password" cssClass="text"/></td>
        </tr>
        <tr>
            <td colspan="2" align="right">
                    <%--<s:submit cssClass="btn" value="%{getText('login.label')}"/>--%>
                <s:submit cssClass="btn" value="%{getText('login.label')}"/>
            </td>
            <s:hidden name="isAndroid" id="isAndroid"/>
        </tr>
            <%--  <tr>
                <td colspan="2" align="left">
                    <span><s:a href="#">
                        <s:label value="%{getText('forgot_password.label')}"/>
                    </s:a></span>
                </td>
            </tr>--%>
    </table>
    </s:form>
    <script type="text/javascript">document.loginForm.username.focus();</script>
</body>

<%--</div>--%>